package Action;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.eventdao;
import Dao.userdao;
import Entity.Event;
import Entity.User;
import mapper.Eventmapper;
import mapper.Usermapper;

/**
 * Servlet implementation class EventServlet
 */
@WebServlet("/EventServlet")
public class EventServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EventServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int sum=0;
		int page = Integer.parseInt(request.getParameter("page"));
		Eventmapper um =new eventdao();
		sum=um.getAllEvent().size();
		if(sum%10==0){
			sum=sum/10;
		}
		else
			{
				sum=sum/10+1;
			}
		List<Event> event= um.getAllEventBypage(page);
		request.setAttribute("event", event);
		request.setAttribute("sum", sum);
		request.setAttribute("cpage", page);
		request.getRequestDispatcher("m_test.jsp").forward(request,response);
	}
}


